package com.zl.gmadmin.mapper;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zl.gmadmin.entity.SysJob;
import com.zl.gmadmin.entity.SysRole;
import com.zl.gmadmin.entity.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Optional;


/**
 * @author zhangliang
 * @version 1.0
 * @date 2021/2/2 15:57
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

    /**
     * 通过用户名查询用户
     * @param usernameOrEmailOrPhone
     * @return
     */
    Optional<SysUser> findByUsernameOrEmailOrPhone(@Param("usernameOrEmailOrPhone") String usernameOrEmailOrPhone);

    /**
     * 导出
     * @param ids 用户id
     * @return
     */
    List<SysUser> findAll(List<Long> ids);

    /**
     * 分页查询
     * @param page
     * @return
     */
    IPage<SysUser> selectPageVo(Page<?> page);



    /**
     *插入用户
     * @param sysUser
     * @return
     */
    int insertUserWithoutRole(SysUser sysUser);

    /**
     * 插入用户何角色关联表
     * @param sysUser
     * @param role
     * @return
     */
    int insertUser_Role(@Param("user")SysUser sysUser, @Param("role") SysRole role);

    /**
     * 插入用户工作关系表
     * @param sysUser
     * @param job
     * @return
     */
    int insertUser_job(@Param("user")SysUser sysUser, @Param("job") SysJob job);

    /**
     * 删除用户角色关联表
     * @param ids
     * @return
     */
    boolean deleteUser_role(List<Long> ids);

    /**
     * 删除用户工作关联表
     * @param ids
     * @return
     */
    boolean deleteUser_job(List<Long> ids);



}
